/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pa165.dominating.species.dao;

import java.util.List;
import pa165.dominating.species.entities.User;
import pa165.dominating.species.exceptions.EntityException;

/**
 *
 * @author Filip Dinh
 */
public interface UserDAO {

    /**
     * Stores user into database. Id for the new user is automatically generated
     * and stored into id attribute.
     *
     * @param user user to be created.
     * @throws PreexistingEntityException when the user is already in database.
     */
    public void createUser(User user);

    /**
     * Updates user in database.
     *
     * @param user updated user to be stored into database.
     * @throws EntityException when user´s id is null(user is not in
     * database).
     */
    public void updateUser(User user);

    /**
     * Deletes user from database.
     *
     * @param user user to be deleted from db.
     * @throws EntityException when user is not in database.
     */
    public void deleteUser(User user);

    /**
     * Returns user with given id.
     *
     * @param id primary key of requested user.
     * @return user with given id or null if such user does not exist.
     */
    public User getUserById(Long id);

    /**
     * Returns list of all users in the database.
     *
     * @return list of all users in database.
     */
    public List<User> getAllUsers();
    
    /**
     * Returns user with given user name.
     *
     * @param username user name of requested user.
     * @return userTO with given user name or null if such user does not exist.
     */
    public User getUserByUserName(String username);
}
